package LeetCode.leetcode110;

public class Review {
    public boolean isBalanced(TreeNode root) {
        if (root == null) return true;
        if (Math.abs(getDeep(root.left) - getDeep(root.right)) > 1) return false;
        return isBalanced(root.left) && isBalanced(root.right);
    }
    public static int getDeep(TreeNode root){
        if (root == null) return 0;
        return Math.max(getDeep(root.left),getDeep(root.right)) + 1;
    }
}
